#include<iostream>
#include<string>
#include<jsoncpp/json/json.h>

int main()
{
    // 序列化
    Json::Value root;
    root["name"]="zs";
    root["high"]=1.76;
    root["sex"]="男";
    std::string s=root.toStyledString();
    std::cout<<s<<std::endl;

    // 反序列化
    Json::Value droot;
    Json::Reader reader;
    reader.parse(s,droot);

    std::string name = droot["name"].asString();
    float high = droot["high"].asFloat();
    std::string sex = droot["sex"].asString();

    std::cout << name << std::endl;
    std::cout << high << std::endl;
    std::cout << sex << std::endl;

    // Json::StyledWriter writer;
    // std::string s = writer.write(root);
    // std::cout << s;

    // Json::FastWriter writer;
    // std::string s=writer.write(root);
    // std::cout<<s<<std::endl;

    // Json::StreamWriterBuilder wbuilder;
    // std::unique_ptr<Json::StreamWriter> writer(wbuilder.newStreamWriter());

    // std::stringstream ss;
    // writer->write(root, &ss);

    // std::cout << ss.str();
    return 0;
}